package com.lanchetech.im.service.impl;

import com.lanchetech.dao.MsgUserMapper;
import com.lanchetech.dao.UserMapper;
import com.lanchetech.entity.MsgUser;
import com.lanchetech.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

public class CustomUserService implements UserDetailsService { //1
    @Autowired
    MsgUserMapper msgUserMapper;

    @Override
    public UserDetails loadUserByUsername(String username) { //2
        MsgUser user = msgUserMapper.findOneByUsername(username);
        if (user == null) {
            throw new UsernameNotFoundException("用户不存在");
        }
        return user;
    }

}
